import Vue from 'vue'
import App from './App.vue'
import router from './router'
import './plugins/element.js'
// 全局样式
import './assets/css/global.css'
// 图标样式资源
import './assets/fonts/iconfont.css'
// 导入axios
import axios from 'axios'
// 导入第三方组件
import TreeTable from 'vue-table-with-tree-grid'
// 导入富文本框组件
import VueQuillEditor from 'vue-quill-editor'
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'
Vue.component('tree-table', TreeTable)
Vue.use(VueQuillEditor)

// 设置请求基准地址
axios.defaults.baseURL = 'http://127.0.0.1:8888/api/private/v1/'
// 挂载axios到Vue构造函数原型
Vue.prototype.$http = axios
// 全局配置每次发请求都带上Authorization：token
axios.interceptors.request.use(config => {
  config.headers.Authorization = window.sessionStorage.getItem('token')
  return config
})

Vue.config.productionTip = false

Vue.filter('dateFormat', function (value) {
  const date = new Date()
  const year = date.getFullYear()
  const month = date.getMonth() + 1
  const day = date.getDate()
  const hours = date.getHours()
  const minutes = date.getMinutes()
  const seconds = date.getSeconds()
  return `${year}-${month}-${day}  ${hours}:${minutes}:${seconds}`
})

new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
